
import { reactive } from 'vue';
function useFetch(url) {
    const state = reactive({
        data: null,
        error: null,
        loading: false
    });
    state.loading = true;
    fetch(url)
        .then(res => res.json())
        .then(res => {
            state.data = res;
        }, error => {
            state.error = error;
        }).finally(() => {
            state.loading = false;
        })
    return state;
}
export default useFetch;